package com.geline.sqlbackup.config;

import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.ArrayList;
import java.util.List;

/**
 #数据库备份
 database-backup:
     list:
     - key: spring.datasource.dynamic.datasource.master
       file-name-with-path: /root/data/{dbName}-{yyyyMMdd}.sql
       cron: 0 0 4 1/1 * ?
       ignore-tables: t_user,t_config
       ignore-table-prefixes: t_user,t_config
       backup-tables: t_user,t_config
       backup-table-prefixes: t_user,t_config
     - key: spring.datasource.dynamic.datasource.master
       file-name-with-path: /root/data/{dbName}-{yyyyMMdd_HHmm}.sql
       cron: 0/20 * * * * ?
       ignore-tables: t_user,t_config
       ignore-table-prefixes: t_user,t_config
       backup-tables: t_user,t_config
       backup-table-prefixes: t_user,t_config
 * @author: mengx
 * @date: 2021/8/15 16:26
 */
@ConfigurationProperties(prefix = "database-backup")
public class SqlBackupProperties {

    /* 数据源配置spring-key */
    private String key = "spring.datasource.dynamic.datasource.master";

    /* 保存路径 */
    private String savePath = "/root/data/";

    //定时任务表达式 测试 20 秒一次【  0/20 * * * * ? 】 每天凌晨4点 【  0 0 4 1/1 * ? 】
    private String cron = "0 0 4 1/1 * ?";

    //保存N天内生成的文件，优先级高于数量
    private Integer maxHistoryDay = 30;

    //备份多个文件
    private List<DatabaseBean> list = new ArrayList<>();

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getSavePath() {
        return savePath;
    }

    public void setSavePath(String savePath) {
        this.savePath = savePath;
    }

    public String getCron() {
        return cron;
    }

    public void setCron(String cron) {
        this.cron = cron;
    }

    public Integer getMaxHistoryDay() {
        return maxHistoryDay;
    }

    public void setMaxHistoryDay(Integer maxHistoryDay) {
        this.maxHistoryDay = maxHistoryDay;
    }

    public List<DatabaseBean> getList() {
        return list;
    }

    public void setList(List<DatabaseBean> list) {
        this.list = list;
    }
}
